<?xml version='1.0' encoding='UTF-8' ?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
    <!--Inicia la composicion de la pagina en la plantilla-->
    <ui:composition template="/resource/template/plantilla.xhtml">

        <!--Segmento que define el contenido del header-->
        <ui:define name="head">
            <h:head>
                <f:loadBundle basename="location.province.label_es" var="label" />
                <f:loadBundle basename="location.province.message_es" var="message" />
                <f:loadBundle basename="location.province.help_#{logged.loggedIdiom}" var="help" />
                <script>
                    function verificar(dato)
                    {
                        var agree = confirm(dato);
                        if (agree)
                            return true;
                        else
                            return false;
                    }
                </script>
            </h:head>
        </ui:define>

        <!--Segmento que define el contenido de la pagina-->
        <ui:define name="content">
            <h:body>
                <h:outputText value="#{message.m0}" class="label" rendered="#{!access.visit}"/>
                <h:form rendered="#{access.visit}">  
                    <p:growl id="messages" showDetail="true"/>  

                    <h:panelGroup>
                        <div class="field">
                            <h:outputText value="#{label.field2}" class="label"/>
                            <h:inputText value="#{location_province.nombre}" class="textfield" required="#{param['required']=='true'}" requiredMessage="#{message.m22}"/>
                            <h:outputText class="required" value="*"/>
                        </div>
                        <h:commandButton value="#{label.button1}" class="button" actionListener="#{location_province.insert}" rendered="#{access.add}" onclick="return verificar('#{message.m7}')">
                            <f:param name="required" value="true"/>
                        </h:commandButton>
                        <h:commandButton value="#{label.button2}" class="button" actionListener="#{location_province.update}" rendered="#{access.update}" onclick="return verificar('#{message.m8}')">
                            <f:param name="required" value="true"/>
                        </h:commandButton>
                        <h:commandButton value="#{label.button3}" class="button" actionListener="#{location_province.delete}" rendered="#{access.delete}" onclick="return verificar('#{message.m9}')"/>
                        <h:commandButton value="#{label.button4}" class="button" actionListener="#{location_province.clear}"/>
                    </h:panelGroup>
                    <!--Dialogos para la insertcion de pais-->
                    <p:dialog id="addPais" widgetVar="addPais" header="#{label.title2}" modal="true" resizable="false">
                        <h:inputText value="#{location_province.countryBeans.nombre}" class="textfield"/>
                        <h:commandButton value="#{label.button1}" class="button" actionListener="#{location_province.insertCountry}" onclick="addPais.hide();"/>
                    </p:dialog>
                </h:form>
                <h:form>
                    <c:set var="list" value="#{location_provinceFind.listByLoggedId}"/>
                    <h:panelGroup layout="block" class="tableWrapper" rendered="#{not empty list}">
                        <h:dataTable var="p" value="#{list}" class="dataTable">
                            <h:column >
                                <h:commandLink styleClass="editButton" rendered="#{access.update}" actionListener="#{location_province.selectedTempId(p.id)}"/>
                            </h:column>
                            <h:column >
                                <f:facet name="header">#{label.field2}</f:facet>
                                <h:outputText value="#{p.nombre}"/>
                            </h:column>
                        </h:dataTable>
                    </h:panelGroup>                
                </h:form>          
            </h:body>
        </ui:define> 
        <ui:define name="slideHelper">
            <h3>#{help.title1}</h3>
            #{help.detail1a}
            <p>
                #{help.title2}
                <ul>
                    <li>#{help.detail2a} </li>
                </ul>
            </p>
            <p>
                #{help.title3}
                <ul>
                    <li>#{help.detail3a} </li>
                    <li>#{help.detail3b} </li>
                    <li>#{help.detail3c} </li>
                </ul>
            </p>
        </ui:define>
    </ui:composition>

</html>

